import {
  http
} from './http.js';
// 登录相关接口
export const loginApi = {
  /**
   * 微信登录
   * @param {string} code - 微信授权code
   * @returns {Promise}
   */
  wechatLogin: (code) => http.post('/login', {
    code
  }).then((res) => {
    if (res.code === 200 && res.data.token) {
      uni.setStorageSync('token', res.data.token);
    }
    return res;
  })
};

//检测状态
export const matchApi = {
  /**
   * @returns {Promise}
   */
  getMatchStatus: () => {
    return http.get('/signup/info')
  }
};

//获取报名详情
export const getsignupApi = {
  /**
   * @param {number} signupId 
   * @returns {Promise}
   */
  getsignup: (signupId) => http.get(`/${signupId}`)
}

//下载pdf文件
export const downLoadPdfApi = {
  /**
   * @param {string} url
   * @returns {Promise}
   */
  downLoadPdf: (url) => {
    return http.get(`/profile/download/?fullPath=${url}`, {}, {}, 'blob')
  }
};

//获取岗位详情信息
export const getpositionApi = {
  /**
   * @param {number} require_id 
   * @returns {Promise<{data: object, status: number}>}
   */
  getposition: (requireId) => http.get(`/wechat/require/${requireId}`)
}